<?php

namespace Home\Controller;

use Think\Controller;
use Think\IFilter;
use Think\IReq;
use Think\ITime;
use Home\Model\Tool;

class MessageController extends Controller{
	public function index(){
		$this->display();
	}
	public function add(){
		$code = IFilter::act(IReq::get("code"));
		if(IS_POST){
			$data['user_ip'] = Tool::getIP();
			$data['sub_time'] = ITime::getNow('Y-m-d H:i:s');
			$data['content'] = I('content');
			$data['username'] = I('username');
			$data['user_phone'] = I('user_phone');

			M('message')->add($data);
			$this->success('留言成功！');
		}
		else{
			$this->error('非法操作');
		}
		//$this->display();
	}
}
?>